using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class EnemyControl1 : MonoBehaviour
{
    public static EnemyControl1 Instance;
    // 移动的方向
    private Vector3 dir;
    // 蜜蜂是否飞行
    public bool isFly = true;
    void Awake()
    {
        Instance = this;
        dir = playerControl.Instance.transform.position - transform.position;
    }

    void Update()
    {
        if(isFly){
            transform.position += dir * Time.deltaTime * 0.3f;
            if(transform.position.y < -1){
                Destroy(gameObject);
            }
        }
    }

    private void OnTriggerEnter2D(Collider2D collider)
    {
        if(collider.tag == "Bullet"){
            Destroy(collider.gameObject);
            Destroy(gameObject);
        }
    }
}
